<script type="text/javascript" src="../../js/ajaxfileupload.js"></script>

<div class="modal-body">
	<form id="user-form" name="user-form" class="form-horizontal">
		<input type="hidden" name="id" id="projectId">
		<input type="hidden" name="createTime" data-flag="date" data-format="yyyy-MM-dd HH:mm:ss">
		<input type="hidden" name="deleted">
		<div class="box-body">
			<div class="col-md-12">
				<div class="form-group">
					<label for="description" class="col-sm-2 control-label">上传文件</label>
					<div class="col-sm-6">
						<div id="uploadfileQueue"></div>
						<input type="file" class="form-control" id="file" name="file" placeholder="上传文件">
					</div>
					<div class="col-sm-4">
						<a id="template" href="javascript:void(0)" onclick="downTemplate()">勘察数据导入模板下载</a>
					</div>
				</div>
			</div>
		</div>
		<!-- /.box-body -->
		<div class="box-footer text-right">
			<!--以下两种方式提交验证,根据所需选择-->
			<button type="button" class="btn btn-default" data-btn-type="cancel" onclick="dialog_close()">取消</button>
			<button type="button" class="btn btn-primary" data-btn-type="save" onclick="importData()">导入</button>
		</div>
		<!-- /.box-footer -->
	</form>
</div>
<script type="text/javascript">
	$(document).ready(function(){
	});
	
	function importData(){
		var url = "../../surveydata/import/";
		$.ajaxFileUpload({  
	        url : url, //用于文件上传的服务器端请求地址  
	        secureuri : false, //一般设置为false  
	        fileElementId : 'file', //文件上传空间的id属性  <input type="file" id="file" name="file" />  
	        type : 'POST',  
	        dataType : 'json', //返回值类型 一般设置为json  
	        success : function( data, status) {//服务器成功响应处理函数  
	        	console.log(data);
	        	var result = JSON.parse(data);
	        	showKnowledgeTable();
	            alert(result.message);
	            dialog_close(); 
	        },  
	        error : function( data, status, e){//服务器响应失败处理函数  
	            alert(data.message);  
	        }  
	    });  
	    return false;  
	}
	
	function downTemplate() {
		var url = "../../template/template_survey_data.xlsx";
		
		window.open(url);
	}
	
	function dialog_close(){
		global.dialog.close()
	}
</script>